package Home_Work.src.day03;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * 2018-03-25 输入一个生产日期格式"yyyy-MM-dd",再输入一个数字(保质期的天数)。
 * 然后经过计算输出促销日期，促销日期为:该商品过期日前2周的周三
 * 
 * @author Bonnie
 * 
 */
public class Test04 {
	public static void main(String[] args) throws ParseException {
		System.out.println("生产日期(yyyy-MM-dd)：");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd E");
		Scanner scanner = new Scanner(System.in);
		String outPutDay = scanner.nextLine();
		Date outPD = sdf.parse(outPutDay);
		System.out.println("保质期：");
		Scanner scanner1 = new Scanner(System.in);
		int decayDay = scanner1.nextInt();
		Calendar cal = Calendar.getInstance();
		cal.setTime(outPD);
		cal.add(Calendar.DATE, decayDay);
		cal.add(Calendar.WEEK_OF_MONTH, -2);
		cal.set(Calendar.DAY_OF_WEEK, 4);
		System.out.println("促销日期为:" + sdf1.format(cal.getTime()));
	}
}
